﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace PlanningGIS.ManageUtility.Modules
{
    /// <summary>
    /// 资源信息实体类
    /// </summary>
    public class ResourceInfo
    {
        /// <summary>
        /// 
        /// </summary>
        public ResourceInfo()
        {
            ID = "";
            Name = "";
            MinScale = 0;
            MaxScale = 0;
            ResType = "1";
        }

        /// <summary>
        /// 唯一编号
        /// </summary>
        public string ID { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 类型
        /// </summary>
        public string ResType { get; set; }
        /// <summary>
        /// 服务器
        /// </summary>
        public string Server { get; set; }
        /// <summary>
        /// 数据名称
        /// </summary>
        public string Database { get; set; }
        /// <summary>
        /// 用户名称
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        public string Parent_ID { get; set; }

        /// <summary>
        /// 是否启用，使用是请用SetEnable，或GetEnable
        /// </summary>
        public string Enable { get; set; }

        /// <summary>
        /// 数据名称（图层名称）
        /// </summary>
        public string DataName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public double MinScale { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public double MaxScale { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string ShowScale { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="enable"></param>
        public void SetEnable(bool enable)
        {
            Enable = enable ? "1" : "0";
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public bool GetEnable()
        {
            return Enable == "1" ? true : false;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="show"></param>
        public void SetShowScale(bool show)
        {
            ShowScale = show ? "1" : "0";
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public bool GetShowScale()
        {
            return ShowScale == "1" ? true : false;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="restype"></param>
        public void SetResType(zjgisResType restype)
        {
            ResType = ((int)restype).ToString(); 
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public zjgisResType GetResType()
        {
            if (string.IsNullOrWhiteSpace(ResType)) ResType = "1";
            return (zjgisResType)Enum.Parse(typeof(zjgisResType), ResType);
        }
    }
    
    /// <summary>
    /// 资源类型
    /// </summary>
    public enum zjgisResType : int
    {
        /// <summary>
        /// 资源组
        /// </summary>
        [Description("资源组")]
        Group = 1,

        /// <summary>
        /// GIS数据源
        /// </summary>
        [Description("GIS数据源")]
        GISDB = 2,

        /// <summary>
        /// 数据集
        /// </summary>
        [Description("数据集")]
        Dataset,


        /// <summary>
        /// 要素类
        /// </summary>
        [Description("要素类")]
        FeatureClass,

        /// <summary>
        /// 栅格数据
        /// </summary>
        [Description("栅格数据")]
        Raster,

        /// <summary>
        /// 视频
        /// </summary>
        [Description("视频")]
        Video,

        /// <summary>
        /// 图片
        /// </summary>
        [Description("图片")]
        Picture,

        /// <summary>
        /// 其他
        /// </summary>
        [Description("其他")]
        Other

    }

}
